package com.qingzhou.web.controller.edc;

import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.qingzhou.common.enums.BusinessType;
import com.qingzhou.common.web.controller.BaseController;
import com.qingzhou.framework.annotation.QzLog;
import com.qingzhou.web.repository.entity.HospitalDistrictEntity;
import com.qingzhou.web.service.HospitalDistrictService;
import com.qingzhou.web.service.impl.params.request.HospitalDistrictAddForm;
import com.qingzhou.web.service.impl.params.request.HospitalDistrictDeleteForm;
import com.qingzhou.web.service.impl.params.request.HospitalDistrictDetailForm;
import com.qingzhou.web.service.impl.params.request.HospitalDistrictEditForm;
import com.qingzhou.web.service.impl.params.vo.HospitalDistrictVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.Result;

import java.util.List;

@Api("医院院区管理")
@Controller
@Mapping("edc/hospitalDistrict")
public class HospitalDistrictController extends BaseController {
    @Inject
    HospitalDistrictService hospitalDistrictService;
    @ApiOperation("新增院区")
    @QzLog(title = "新增院区", businessType = BusinessType.INSERT)
    //@AuthPermissions("edc:checkRecords:add")
    @Post
    @Mapping("add")
    public Result<Void> add(HospitalDistrictAddForm form) {
        return toResult(hospitalDistrictService.add(form));
    }

    @ApiOperation("删除院区")
    @QzLog(title = "删除院区", businessType = BusinessType.DELETE)
    //@AuthPermissions("edc:checkRecords:delete")
    @Post
    @Mapping("delete")
    public Result<Void> delete(HospitalDistrictDeleteForm form) {
        return toResult(hospitalDistrictService.delete(form));
    }

    //@AuthPermissions("edc:checkRecords:page")
    @Post
    @Mapping("page")
    @ApiOperation("院区分页")
    public Page<HospitalDistrictEntity> page(Page<HospitalDistrictEntity> page,HospitalDistrictEntity entity) {
        return hospitalDistrictService.page(page, QueryWrapper.create(entity));
    }

    //@AuthPermissions("edc:checkRecords:detail")
    @Get
    @Mapping("detail")
    @ApiOperation("院区详情")
    public HospitalDistrictVo detail(HospitalDistrictDetailForm form) {
        return hospitalDistrictService.detail(form);
    }

    @Get
    @ApiOperation("查单个院区")
    @Mapping("queryOne")
    public HospitalDistrictEntity queryOne(HospitalDistrictEntity entity) {
        return hospitalDistrictService.getOne(QueryWrapper.create(entity));
    }

    @Get
    @ApiOperation("查多个院区")
    @Mapping("list")
    public List<HospitalDistrictEntity> list(HospitalDistrictEntity entity) {
        return hospitalDistrictService.list(QueryWrapper.create(entity));
    }

    @ApiOperation("编辑院区")
    @QzLog(title = "编辑院区", businessType = BusinessType.INSERT)
    //@AuthPermissions("edc:checkRecords:edit")
    @Post
    @Mapping("edit")
    public Result<Void> edit(HospitalDistrictEditForm form) {
        return toResult(hospitalDistrictService.edit(form));
    }
}
